<%--
  Created by IntelliJ IDEA.
  User: ASUS
  Date: 2021/12/18
  Time: 14:58
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>离职员工信息</title>
    <link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/layui/css/layui.css"/>
    <script type="text/javascript" src="${pageContext.request.contextPath}/layui/layui.js"></script>

</head>
<body>
<form class="layui-form" action="">
    <div class="layui-form-item">
        <div class="layui-inline">
            <div class="layui-input-inline">
                <input type="text" name="staffname" placeholder="请输入员工姓名"  autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <div class="layui-input-inline">
                <input type="text" name="staffid"  placeholder="请输入员工工号" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <div class="layui-input-inline">
                <button type="button" class="layui-btn" lay-submit="" lay-filter="search">搜索</button>
            </div>
        </div>
    </div>
</form>
<table class="layui-hide" id="test" lay-filter="test"></table>

</div>

<script>
    layui.use(['table','form','jquery','layer','element'], function() {
        var table = layui.table;
        var form = layui.form;
        var $=layui.jquery;
        var layer=layui.layer;
        var upload=layui.upload;
        var element=layui.element;


        //添加表单的搜索监听事件
        form.on('submit(search)',function(data){
            //表格数据重新渲染。
            table.reload('test',{
                page: {
                    curr: 1 //重新从第 1 页开始
                },
                where: { //按照什么进行查找
                    "staffname": data.field.staffname,
                    "staffid": data.field.staffid,
                }
            })
        });


        table.render({
            elem: '#test'
            // ,id:"test"
            , url: '${pageContext.request.contextPath}/outitstaff/listByCondition'
            , toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
            , title: '离职员工数据表'
            , cols: [[
                {type: 'checkbox', fixed: 'left'}
                , {field: 'staffid', title: '员工工号',  sort: true}
                , {field: 'staffname', title: '员工姓名'}
                , {field: 'idcard', title: '身份证号码' }
                , {field: 'address', title: '地址'}
                , {field: 'phone', title: '电话号码'}
                , {field: 'entrytime', title: '入职时间'}
                , {field: 'leavetime', title: '离职时间'}
                , {field: 'state', title: '状态',templet:function (e) {
                        return e.state==0?
                            "<button class='layui-btn layui-btn-xs layui-btn-danger'>离职</button>":state;
                    }
                }
                , {field: 'branchid', title: '店名',templet:function (a) {
                        return a.branch==null?"":a.branch.branchname;
                    }
                }
                , {field: 'roleid', title: '职位',templet:function (b) {
                        return b.role==null?"":b.role.rolename;
                    }}
                , {field: 'deptid', title: '部门名称',templet:function (c) {
                        return c.dpm==null?"":c.dpm.deptname;
                    }}
                , {field: 'remark', title: '职位描述',templet:function (d) {
                        return d.dpm==null?"":d.dpm.remark;
                    }}
            ]]
            , page: true
            , limit: 4 //默认每页显示5条
            , limits:[2,4,10,15]
        });
    });
</script>
</body>
</html>

